package net.sinmetal.twitcockpit.controller.admin;

import java.util.Calendar;
import java.util.Date;

import net.sinmetal.twitcockpit.util.DateUtil;

import org.slim3.controller.Controller;
import org.slim3.controller.Navigation;
import org.slim3.util.TimeZoneLocator;

public class IndexController extends Controller {

    @Override
    public Navigation run() throws Exception {
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeZone(TimeZoneLocator.get());

        Calendar hoge = org.slim3.util.DateUtil.toCalendar(calendar.getTime());
        int year = hoge.get(Calendar.YEAR);
        int month = hoge.get(Calendar.MONTH) + 1;
        int date = hoge.get(Calendar.DATE);
        int hour = hoge.get(Calendar.HOUR);
        int minute = hoge.get(Calendar.MINUTE);

        String hogeText =
            String.format("%s/%s/%s %s:%s", year, month, date, hour, minute);
        requestScope("hogeText", hogeText);

        String format =
            DateUtil.format(calendar.getTime(), "yyyy/MM/dd HH:mm:ss (E)");
        requestScope("format", format);

        Date fuga =
            org.slim3.util.DateUtil.toDate(format, "yyyy/MM/dd HH:mm:ss");
        requestScope("fuga", fuga);

        String hh = DateUtil.format(calendar.getTime(), "HH");
        String mm = DateUtil.format(calendar.getTime(), "mm");
        String e = DateUtil.format(calendar.getTime(), "E");
        requestScope("moge", hh + ":" + mm + "(" + e + ")");

        return forward("index.jsp");
    }
}
